package com.joven.shelltest.controller;

import com.joven.shelltest.service.ThreadPoolTestService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.ThreadPoolExecutor;

/**
 * @Author: wzj
 * @Date: 2024/1/31 15:19
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/threadPool")
public class ThreadPoolController {

//    @Autowired
//    @Qualifier(value = "jovenThreadPool")
//    private ThreadPoolExecutor threadPoolExecutor;

//    @GetMapping("/getThreadPoolInfo")
//    public void getThreadPoolInfo(){
//        System.out.println("getActiveCount--"+threadPoolExecutor.getActiveCount());
//        System.out.println("getCorePoolSize--"+threadPoolExecutor.getCorePoolSize());
//        System.out.println("getPoolSize--"+threadPoolExecutor.getPoolSize());
//    }

    private final ThreadPoolTestService threadPoolTestService;

    @GetMapping("/testAsync")
    public void test2() throws InterruptedException {
        System.out.println("进入test2 "+System.currentTimeMillis());
        threadPoolTestService.service1();
        System.out.println("调用结束 "+System.currentTimeMillis());
    }


}
